import inquirer from "inquirer";
import { initProject } from "./init-project.js";
import { initConfigFile } from "./init-config.js";
export default function (config) {
  inquirer
    .prompt([
      {
        type: "input",
        name: "projectName",
        message: "请输入项目名称",
      },
      {
        type: "list",
        name: "type",
        message: "请选择当前项目的类型:",
        choices: config.types,
        default: "backend",
      },
    ])
    .then((answers) => {
      inquirer
        .prompt([
          {
            type: "checkbox",
            name: "module",
            message: "请选择需要添加的模块:",
            choices: config.modules.filter((it) => it.type === answers.type),
            default: [],
          },
        ])
        .then((answ) => {
          answers.module = answ.module;
          initProject(answers, config);
          initConfigFile(answers, config);
        });
    });
}
